package com.crud.adapter.controller;

import com.crud.application.HiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/hive")
public class HiveController {

    @Autowired
    private HiveService hiveService;

    // 查询数据
    @GetMapping("/query")
    public List<Map<String, Object>> query(@RequestParam String sql) {
        return hiveService.getHiveData(sql);
    }

    // 插入数据
    @PostMapping("/insert")
    public int insert(@RequestParam String sql) {
        return hiveService.insertHiveData(sql);
    }

    // 更新数据
    @PutMapping("/update")
    public int update(@RequestParam String sql) {
        return hiveService.updateHiveData(sql);
    }

    // 删除数据
    @DeleteMapping("/delete")
    public int delete(@RequestParam String sql) {
        return hiveService.deleteHiveData(sql);
    }
}
